package cn.dengta.webapp.trade.service;

import java.util.List;

import cn.dengta.context.model.WesKit;
import cn.dengta.webapp.base.service.BaseServiceImpl;
import cn.dengta.webapp.trade.dao.IntegralExchangeCoinConfigDao;
import cn.dengta.webapp.trade.entity.IntegralExchangeCoinConfig;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import me.codeplayer.util.X;
import org.springframework.stereotype.Service;

import static cn.dengta.webapp.base.entity.BaseEntity.ID;
import static cn.dengta.webapp.trade.entity.IntegralExchangeCoinConfig.INTEGRAL;

/**
 * 积分兑换钻石配置 服务实现类
 *
 * @author hsj
 * @since 2024-02-23
 */
@Service
public class IntegralExchangeCoinConfigService extends BaseServiceImpl<IntegralExchangeCoinConfig, IntegralExchangeCoinConfigDao, Long> {

	public boolean incCount(Long id) {
		if (!X.isValid(id)) {
			return false;
		}
		return this.baseDao.incCount(id) > 0;
	}

	public List<IntegralExchangeCoinConfig> findAllIntegralExchangeCoinByCache(WesKit wesKit) {
		final QueryWrapper<IntegralExchangeCoinConfig> qw = new QueryWrapper<>();
		qw.apply(wesKit != null, "FIND_IN_SET({0}, wes_kits)", wesKit);
		qw.orderByDesc(INTEGRAL, ID);
		return selectList(qw);
	}
}
